package xml1;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

public class Dom4JTest2 {
    public static void main(String[] args) {
//        使用StringBuilder来拼接xml文件格式的数据
        StringBuilder sb = new StringBuilder();
        sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n");
        sb.append("<book>\r\n");
        sb.append("\t<name>从入门到跑路</name>\r\n");
        sb.append("\t<author>dlei</author>\r\n");
        sb.append("\t<price>999.99</price>\r\n");
        sb.append("</book>");

        try (
                BufferedWriter bw =
                        new BufferedWriter(new FileWriter("src\\book.xml"));
                ) {
            bw.write(sb.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
